import sys,qdarkstyle
from PyQt5 import QtCore,QtGui,uic,QtWidgets
import mail,send_ui
import PyQt5_stylesheets
# form_class=uic.loadUiType("send.ui")[0]
class window(QtWidgets.QMainWindow,send_ui.Ui_MainWindow):
	def __init__(self,parent=None,style='qds'):
		QtWidgets.QMainWindow.__init__(self,parent)
		self.setupUi(self)
		
		# self.setStyleSheet(qdarkstyle.load_stylesheet_pyqt())
		try:
			self.whenClose=style
			if self.whenClose=='skyblue':
				self.cskyblue()
			elif self.whenClose=='dark':
				self.cdark()
			elif self.whenClose=='darkOrange':
				self.cdarkOrange()
			elif self.whenClose=='pinkblue':
				self.cpinkblue()
			elif self.whenClose=='light':
				self.light()
			else:
				self.setStyleSheet(self.qds)
		except:
			self.setStyleSheet(qdarkstyle.load_stylesheet_pyqt5())
		
	def send(self):
		try:
			sender=self.sender.text()
			password=self.password.text()
			smtp=self.smtp_name.text()
			to=self.to.text()
			subject=self.subject.text()
			text=self.text.toPlainText()

			a=mail.send_plain_text(sender,password,smtp,to,subject,text)
			if a==True:
				QtGui.QMessageBox.information(self, 'send', '发送成功！')
			else:
				QtGui.QMessageBox.information(self, 'send', '发送失败！')
		except:
			QtGui.QMessageBox.information(self, 'send', '发送失败！')
	def cpinkblue(self):
		(0.8)
		self.setStyleSheet('')
		self.setStyleSheet('background-color: pink;')
		self.setStyleSheet('background-color: pink;QMainWindow,QMenu,QAction{background-color: pink;color: black;}QMenuBar::item {background: transparent;}')
	def cdark(self):
		try:
			self.setStyleSheet(PyQt5_stylesheets.load_stylesheet_pyqt5(style="style_Dark"))
		except Exception as E:
			print(E)
	def cskyblue(self):
		self.setStyleSheet('background-color: skyblue;QMainWindow,QMenu,QAction{background-color: skyblue;color: black;}QMenuBar::item {background: transparent;}')
	
	def cdarkOrange(self):
		(0.84)
		# with open('GUIs/style/darkorange','r')as style:
		# 	stylesheet=style.read()
		try:
			self.setStyleSheet(PyQt5_stylesheets.load_stylesheet_pyqt5(style="style_DarkOrange"))
		except:
			pass

	def qd(self):
		self.setStyleSheet('')
		self.setStyleSheet(self.qds)

	def light(self):
		(0.82)
		self.setStyleSheet('')


# app=QtGui.QApplication(sys.argv)
# myWindow=window()
# myWindow.show()
# app.exec_()